year = int(input('请输入年份'))
month  = int(input('请输入月份'))
#计算1900到输入年份1月1日的天数
yearsum = 0
i = 1900
while i< year  :
    if i%4==0 and i%100 != 0 or i%400 ==0 :
        yearsum += 366
    else:
        yearsum += 365
    i += 1
#print(yearsum)
#计算输入月份的前一个月到1月1号的天数
j = 1
daysum = 0
while j< month :
    if j==1 or j==3 or j==5 or j==7 or j==8 or j==10 or j==12 : 
        daysum += 31
    elif j==4 or j==6 or j==9 or j==11:
        daysum += 30
    elif j==2:
        if (year%4==0 and year%100 != 0) or year%400 ==0 :
            daysum += 29
        else:
            daysum += 28
    j+=1
sum = yearsum+daysum
#print(sum)
week =(sum)%7+1
#print(week)
day = 0
l = 1
if month==1 or month==1 or month==3 or month==5 or month==7 or month==8 or month==10 or month==12 :
    day = 31
elif month==4 or month==6 or month==9 or month==11 :
    day = 30
elif month==2:
    if (year%4==0 and year%100 != 0) or year%400 ==0 :
        day += 29
    else:
        day += 28
#打印日历格式
print('--------------------'+str(year)+'年'+str(month)+'月'+'--------------------')
print('--------------------------------------------------')
print('星期日','星期一','星期二','星期三','星期四','星期五','星期六',end='\t')
print()

temp = 0
while temp<week:
    if week==7:
        break
    else:
        print('\t',end='')
    temp +=1

while  l<= day:
    print(l,end='\t')
    if (temp+l)%7==0 :
        print()
    l +=1








